import React, { Component } from 'react';
import { HashRouter, Route, Switch, Redirect } from 'react-router-dom';
import App from './App';
import Login from './pages/login';
import NotMatch from './pages/404';
//主要页面
import Main from './Main';
import Lately from './pages/main/lately';
import Whole from './pages/main/whole';
import Share from './pages/main/share/';
import ShareDir from './pages/main/sharegroup';
import Picture from './pages/main/picture';
import Video from './pages/main/video';
import Audio from './pages/main/audio';
import Doc from './pages/main/document';
import Other from './pages/main/other';
import Recycle from './pages/main/recycle';
//后台页面
import Setting from './Setting';
//个人设置页面
import PersonalSetting from './pages/personal';
import PersonalInfo from './pages/personal/userInfo';
import ChangePwd from './pages/personal/changePwd';
//后台管理页面
import BackSetting from './pages/back';
import Theme from './pages/back/theme';
import Monitor from './pages/back/monitor';
import User from './pages/back/user';
import Role from './pages/back/role';
import Notice from './pages/back/notice';
import Ip from './pages/back/ip';
import Ext from './pages/back/ext';
import Api from './pages/back/api';
import Menu from './pages/back/menu';
import Log from './pages/back/log';
//分享链接页面
import ShareLink from './pages/share';
import PrivateRoute from './PrivateRoute';

class IRouter extends Component {
	render(){
		return (
			<HashRouter>
				<App>
					<Switch>
						<Route path="/login" component={Login} />
						<Route path="/main" render={
							() =>
							<Main>
								<Switch>
									<PrivateRoute path="/main/lately" component={Lately} />
									<PrivateRoute path="/main/whole" component={Whole} />
									<PrivateRoute path="/main/picture" component={Picture} />
									<PrivateRoute path="/main/video" component={Video} />
									<PrivateRoute path="/main/audio" component={Audio} />
									<PrivateRoute path="/main/document" component={Doc} />
									<PrivateRoute path="/main/other" component={Other} />
									<PrivateRoute path="/main/share" component={Share} />
									<PrivateRoute path="/main/xsharedir" component={ShareDir} />
									<PrivateRoute path="/main/recycle" component={Recycle} />
								</Switch>
							</Main>
						} />
						<Route path="/setting" render={
							()=>
							<Setting>
								<Switch>
									<Route path="/setting/personal" render={()=>
										<PersonalSetting>
											<Switch>
												<PrivateRoute path="/setting/personal/info" component={PersonalInfo} />
												<PrivateRoute path="/setting/personal/pwd" component={ChangePwd} />
											</Switch>
										</PersonalSetting>
									} />
									<Route path="/setting/back" render={()=>
										<BackSetting>
											<Switch>
												<PrivateRoute path="/setting/back/theme" component={Theme} />
												<PrivateRoute path="/setting/back/monitor" component={Monitor} />
												<PrivateRoute path="/setting/back/user" component={User} />
												<PrivateRoute path="/setting/back/role" component={Role} />
												<PrivateRoute path="/setting/back/notice" component={Notice} />
												<PrivateRoute path="/setting/back/ip" component={Ip} />
												<PrivateRoute path="/setting/back/ext" component={Ext} />
												<PrivateRoute path="/setting/back/api" component={Api} />
												<PrivateRoute path="/setting/back/menu" component={Menu} />
												<PrivateRoute path="/setting/back/log" component={Log} />
											</Switch>
										</BackSetting>
									} />
									
								</Switch>
							</Setting>
						} />
						<Route path="/shareLink/:id" component={ShareLink} />
						<Route exact path="/">
							<Redirect to="/main/whole" />
						</Route>
						<Route component={NotMatch} />
					</Switch>
				</App>
			</HashRouter>
		)
	}
}

export default IRouter;